using System.Data;
using System.Data.SqlClient;
namespace VanTaiData
{
	public class clsTMCustomersController
	{
	    private clsConnect cls = new clsConnect();
        private DataTable dt;
	    #region[Get-Data]
	    public DataTable BindGirdTMCustomers()
	    {
            return cls.BindGridData("sp_TMCustomers");
	    }
	    public DataTable BindGirdTMCustomers_Detail_Edit(int id)
	    {
            return cls.LayDuLieuParameter("sp_TMCustomers_Detail_Edit", "@Id", id);
	    }
	    #endregion

	    #region [Insert-Update-Delete]
	    public bool InsertTMCustomers(clsTMCustomersProperty data)
	    {
	        cls.CreateNewSqlCommand();
	        cls.AddParameter("@Customers_Alias", data.Customers_Alias);
	        cls.AddParameter("@Customers_Name", data.Customers_Name);
	        cls.AddParameter("@Customers_Name_E", data.Customers_Name_E);
	        cls.AddParameter("@Customers_Name_C", data.Customers_Name_C);
	        cls.AddParameter("@Customers_Trade_Names", data.Customers_Trade_Names);
	        cls.AddParameter("@Customers_CMT", data.Customers_CMT);
	        cls.AddParameter("@Customers_Address", data.Customers_Address);
	        cls.AddParameter("@Customers_Brithday", data.Customers_Brithday);
	        cls.AddParameter("@Customers_Phone_Number", data.Customers_Phone_Number);
	        cls.AddParameter("@Customers_Districts_ID", data.Customers_Districts_ID);
	        cls.AddParameter("@Customers_Province_ID", data.Customers_Province_ID);
	        cls.AddParameter("@Customers_Dational_ID", data.Customers_Dational_ID);
	        cls.AddParameter("@Customers_Domain_ID", data.Customers_Domain_ID);
	        cls.AddParameter("@Customers_Fax", data.Customers_Fax);
	        cls.AddParameter("@Customers_Email", data.Customers_Email);
	        cls.AddParameter("@Customers_Tax_Code", data.Customers_Tax_Code);
	        cls.AddParameter("@Customers_Account_Code", data.Customers_Account_Code);
	        cls.AddParameter("@Customers_Type_DN_ID", data.Customers_Type_DN_ID);
	        cls.AddParameter("@Customers_Alternative_Materials_ID", data.Customers_Alternative_Materials_ID);
	        cls.AddParameter("@Customers_Status", data.Customers_Status);
	        cls.AddParameter("@Customers_Degree", data.Customers_Degree);
	        cls.AddParameter("@Customers_Subjective_Units", data.Customers_Subjective_Units);
	        cls.AddParameter("@Customers_Supply_ID", data.Customers_Supply_ID);
	        cls.AddParameter("@Customers_Person_Responsible", data.Customers_Person_Responsible);
	        cls.AddParameter("@Customers_Status_Review", data.Customers_Status_Review);
	        cls.AddParameter("@Customers_Note", data.Customers_Note);
	        cls.AddParameter("@Customers_Division_ID", data.Customers_Division_ID);
	        cls.AddParameter("@Customers_Day_Signed", data.Customers_Day_Signed);
	        cls.AddParameter("@Customers_Day_Liquidation", data.Customers_Day_Liquidation);
	        cls.AddParameter("@Customers_Dealer_ID", data.Customers_Dealer_ID);
	        cls.AddParameter("@Customers_Minutes_Number", data.Customers_Minutes_Number);
	        cls.AddParameter("@Customers_General_Name", data.Customers_General_Name);
	        cls.AddParameter("@Customers_Branch_ID", data.Customers_Branch_ID);
            cls.ExecuteNonQuery("sp_TMCustomers_Insert");
	        return true;
	    }
        public bool UpdateTMCustomers(clsTMCustomersProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Customers_ID", data.Customers_ID);
            cls.AddParameter("@Customers_Alias", data.Customers_Alias);
            cls.AddParameter("@Customers_Name", data.Customers_Name);
            cls.AddParameter("@Customers_Name_E", data.Customers_Name_E);
            cls.AddParameter("@Customers_Name_C", data.Customers_Name_C);
            cls.AddParameter("@Customers_Trade_Names", data.Customers_Trade_Names);
            cls.AddParameter("@Customers_CMT", data.Customers_CMT);
            cls.AddParameter("@Customers_Address", data.Customers_Address);
            cls.AddParameter("@Customers_Brithday", data.Customers_Brithday);
            cls.AddParameter("@Customers_Phone_Number", data.Customers_Phone_Number);
            cls.AddParameter("@Customers_Districts_ID", data.Customers_Districts_ID);
            cls.AddParameter("@Customers_Province_ID", data.Customers_Province_ID);
            cls.AddParameter("@Customers_Dational_ID", data.Customers_Dational_ID);
            cls.AddParameter("@Customers_Domain_ID", data.Customers_Domain_ID);
            cls.AddParameter("@Customers_Fax", data.Customers_Fax);
            cls.AddParameter("@Customers_Email", data.Customers_Email);
            cls.AddParameter("@Customers_Tax_Code", data.Customers_Tax_Code);
            cls.AddParameter("@Customers_Account_Code", data.Customers_Account_Code);
            cls.AddParameter("@Customers_Type_DN_ID", data.Customers_Type_DN_ID);
            cls.AddParameter("@Customers_Alternative_Materials_ID", data.Customers_Alternative_Materials_ID);
            cls.AddParameter("@Customers_Status", data.Customers_Status);
            cls.AddParameter("@Customers_Degree", data.Customers_Degree);
            cls.AddParameter("@Customers_Subjective_Units", data.Customers_Subjective_Units);
            cls.AddParameter("@Customers_Supply_ID", data.Customers_Supply_ID);
            cls.AddParameter("@Customers_Person_Responsible", data.Customers_Person_Responsible);
            cls.AddParameter("@Customers_Status_Review", data.Customers_Status_Review);
            cls.AddParameter("@Customers_Note", data.Customers_Note);
            cls.AddParameter("@Customers_Division_ID", data.Customers_Division_ID);
            cls.AddParameter("@Customers_Day_Signed", data.Customers_Day_Signed);
            cls.AddParameter("@Customers_Day_Liquidation", data.Customers_Day_Liquidation);
            cls.AddParameter("@Customers_Dealer_ID", data.Customers_Dealer_ID);
            cls.AddParameter("@Customers_Minutes_Number", data.Customers_Minutes_Number);
            cls.AddParameter("@Customers_General_Name", data.Customers_General_Name);
            cls.AddParameter("@Customers_Branch_ID", data.Customers_Branch_ID);
            cls.ExecuteNonQuery("sp_TMCustomers_Update");
            return true;
        }
        public bool DeleteTMCustomers(int id)
        {
            cls.Delete("sp_TMCustomers_Delete", "Customers_ID", id);
            return true;
        }
        public bool TMCustomers_Check_Delete_TMCommandTransferOrder(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMCustomers_Check_Delete_TMCommandTransferOrder", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        public bool TMCustomers_Check_Delete_TMPlan_TransferOrder(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMCustomers_Check_Delete_TMPlan_TransferOrder", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        public bool TMCustomers_Check_Delete_TMSalesReport(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMCustomers_Check_Delete_TMSalesReport", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        public bool TMCustomers_Check_Contract(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMCustomers_Check_Contract", "@ID", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
	    #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMCustomers_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}